#include <nixonbot/core/bncs/protocol/MessageFactory.h>

namespace nixonbot {
namespace core {
namespace bncs {
namespace protocol {

MessageFactoryClientRegistrar::MessageFactoryClientRegistrar(int id, Message* msg)
{
	MessageFactory::clientMessageTable.insert(id, msg);
}

MessageFactoryServerRegistrar::MessageFactoryServerRegistrar(int id, Message* msg)
{
	MessageFactory::serverMessageTable.insert(id, msg);
}

Message* MessageFactory::newClientMessage(int id)
{
	/* Returns NULL if the id is not mapped. */
	return clientMessageTable.value(id)->create();
}

Message* MessageFactory::newServerMessage(int id)
{
	/* Returns NULL if the id is not mapped. */
	return serverMessageTable.value(id)->create();
}

}
}
}
}
